﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Report3.aspx.cs" Inherits="PromotionEngine.Report3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div id="example">
    <div class="demo-section k-content">
        <div id="chart"></div>
    </div>
    <div class="box" style="display:none">
        <div class="box-col">
            <h4>Labels Configuration</h4>
            <ul class="options">
                <li>
                    <input id="labels" checked="checked" type="checkbox" autocomplete="off" />
                    <label for="labels">Show labels</label>
                </li>
                <li>
                    <input id="alignCircle" name="alignType" type="radio"
                           value="circle" checked="checked" autocomplete="off" />
                    <label for="alignCircle">Aligned in circle</label>
                </li>
                <li>
                    <input id="alignColumn" name="alignType" type="radio"
                           value="column" autocomplete="off" />
                    <label for="alignColumn">Aligned in columns</label>
                </li>
            </ul>
        </div>
    </div>
    <script>
        function createChart() {
            $("#chart").kendoChart({
                title: {
                    text: "What is you favourite sport?"
                },
                legend: {
                    position: "top"
                },
                seriesDefaults: {
                    labels: {
                        template: "#= category # - #= kendo.format('{0:P}', percentage)#",
                        position: "outsideEnd",
                        visible: true,
                        background: "transparent"
                    }
                },
                series: [{
                    type: "pie",
                    data: [{
                        category: "Football",
                        value: 35
                    }, {
                        category: "Basketball",
                        value: 25
                    }, {
                        category: "Volleyball",
                        value: 20
                    }, {
                        category: "Rugby",
                        value: 10
                    }, {
                        category: "Tennis",
                        value: 10
                    }]
                }],
                tooltip: {
                    visible: true,
                    template: "#= category # - #= kendo.format('{0:P}', percentage) #"
                }
            });
        }

        $(document).ready(function () {
            createChart();
            $(document).bind("kendo:skinChange", createChart);
            $(".box").bind("change", refresh);
        });

        function refresh() {
            var chart = $("#chart").data("kendoChart"),
                pieSeries = chart.options.series[0],
                labels = $("#labels").prop("checked"),
                alignInputs = $("input[name='alignType']"),
                alignLabels = alignInputs.filter(":checked").val();

            chart.options.transitions = false;
            pieSeries.labels.visible = labels;
            pieSeries.labels.align = alignLabels;

            alignInputs.attr("disabled", !labels);

            chart.refresh();
        }
    </script>
</div>
</asp:Content>
